home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / asm_msc1.arc / EX43.ASM < prev    next >
Assembly Source File  |  1988-11-20  |  768b  |  20 lines

  1. TITLE  Word-Averaging Procedure (EX43.ASM)
  2.           PAGE      ,132
  3. OUR_CODE  SEGMENT   PARA 'CODE'
  4.       PUBLIC    AVERAGE
  5. AVERAGE   PROC      FAR
  6.           ASSUME    CS:OUR_CODE
  7.           SUB       AX,AX           ;Clear dividend to start
  8.       SUB       DX,DX
  9.       PUSH      CX              ;Save word count on stack
  10. ADD_W:    ADD       AX,[BX]         ;Add next word to total
  11.           ADC       DX,0
  12.       ADD       BX,2            ;  and update the total
  13.           LOOP      ADD_W           ;All words now totaled?
  14.           POP       CX              ; Yes.  Retrieve word count
  15.       DIV       CX            ;  and take the average
  16.       RET
  17. AVERAGE   ENDP
  18. OUR_CODE  ENDS
  19.          END       AVERAGE
  20.